#include <iostream>
#include <string>

using namespace std;

int main()
{
	int max = 0;
	for(int i = 999; i>0; i--)
	{
		for(int j = 999; j>=i; j--)
		{
			char str[33];
			itoa(i*j,str,10);
			int s = strlen(str), k = 0;
			int n = s--/2;
			while(k<n && str[k] == str[s-k]) k++;
			if (k>=n && i*j>max) max = i*j;
		}
	}
	cout << max << endl;
	return 1;
}
